<?php
/*
 * Created on Oct 30, 2013
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
?>


<style type="text/css">
<!--
    
    div.page {
        border: 1px solid #ddd9e9; 
    }
    
    /* title */
    div#title {
        color : #bd5741;
    }
    div#title > h3.title{
        margin-left: 2%;
    }
    
    /* profile */
    div.profile {
        padding: 10px;
        padding-top: 0px;
    }
    div.profile > p.title{
        color: #525252;
    }
  
-->
</style>

<!-- navbar -->
    <table width="100%" cellspacing="0" cellpadding="0">
    <tbody>
    <tr>
    <td height="25px" align="left" class="header"> 
    <a title="Home" class="home" href="/">&nbsp;Home</a><span class="mark">&nbsp;&raquo;&nbsp;</span> <span class="home">Account Setting</span> 
    </td>
    </tr>
    <tr>
    	<td colspan="1">&nbsp; </td>
    </tr>
    </tbody>
    </table>
    
<?=$menu?>

<div name='profile_setting' class='content_right'>
    
    
    <div class="page">
        <div id="title">
            <h3 class="title">.::. Account Setting</h3>
        </div>
        <div class="profile">
            <p class="title">Enter your personal information </p>
            <div id="message"></div>
            <table style="width:90%;margin-left:5%;" class="pageContent">
    			<tbody>				
    			<tr>
    				<td class="req">User Name:</td>
    				<td><?=$user_detail->email?></td>
    			</tr>
                <tr>
    				<td class="req">Player's Nickname: </td>
    				<td><?=$user_detail->nickname?></td>
    			</tr>	
    			<tr>
    				<td class="req"><span class="colortext">*</span>Password:</td>
    				<td valign="top" style="height:30px;"><a href="javascript:show_change_password()" class="subbutton">Change Password</a></td>
    			</tr>		
    			<tr>
    				<td class="req"><span class="colortext">*</span>First Name:</td>
    				<td><input type="text" maxlength="100" size="50" value="<?=$user_detail->first_name?>" name="firstname"></td>
    			</tr>
    			<tr>
    				<td class="req"><span class="colortext">*</span>Last Name:</td>
    				<td><input type="text" maxlength="100" size="50" value="<?=$user_detail->last_name?>" name="lastname"></td>
    			</tr>
                <tr>
                    <td class="req">Auto withdraw point from game:</td>
                    <td>
                        <select name="auto_withdraw">
                            <option value="0" <?=($player->auto_withdraw==0)?'selected':''?>>No</option>
                            <option value="1" <?=($player->auto_withdraw==1)?'selected':''?>>Yes</option>
                        </select>
                    </td>
                </tr>
    		
	
    			<tr>
    				<td class="spacer" colspan="2">&nbsp;</td>
    			</tr>
                <tr>
    			<td width="32%">
        			<input type="hidden" value="<?=$user_detail->id?>" name="id" id="id">
        			<td class="buttonRow">
        				<a href="javascript:submit_update_profile_setting()" class="button">Update</a> &nbsp; 
        				<a href="/" class="button">Cancel</a> 
        			</td>
        		</tr>						
    			</tbody>
    			</table>        
        <div style="clear: both;"></div>
    </div>
</div>
</div>
<div name="change_password" style="display: none;" class='content_right'>
    
    
    <div class="page">
        <div id="title">
            <h3 class="title">.::. Change your password</h3>
        </div>
        <div class="profile">
            <div id="message2"></div>
            <table style="width:90%;margin-left:5%;" class="pageContent">
            <tbody>
            	<tr>
            		<td class="req"><span class="colortext">*</span>Current password:</td>
            		<td style="height:30px;"><input type="password" maxlength="50" size="30" value="" name="password"></td>
            	</tr>
            	<tr>
            		<td class="req"><span class="colortext">*</span>New password:</td>
            		<td style="height:30px;"><input type="password" maxlength="50" size="30" value="" name="newpassword"></td>
            	</tr>
            	<tr>
            		<td class="req"><span class="colortext">*</span>Confirm new password:</td>
            		<td style="height:30px;"><input type="password" maxlength="50" size="30" value="" name="confirmnewpassword"></td>
            	</tr>
            	<tr>
            		<td width="32%">&nbsp;</td>
            		<td class="buttonRow">
            			<a href="javascript:submit_change_password()" class="button">Change</a> &nbsp; 
            			<a href="javascript:show_profile_setting()" class="button">Back</a> 
            		</td>
            	</tr>
            </tbody>
            </table>    
        <div style="clear: both;"></div>
    </div>
</div>
</div>
<script type="text/javascript">
<!--
    function show_profile_setting()
    {
        $('div[name=change_password]').hide();
        $('div[name=profile_setting]').show();
    }
    function show_change_password()
    {
        $('div[name=change_password]').show();
        $('div[name=profile_setting]').hide();
    }
	function submit_update_profile_setting()
    {
        $('#message').empty();
        $('#message').show();
        $.post( '/account/ajax_updateProfileSetting/', 
            {
                'first_name': $('input[name=firstname]').val(),
                'last_name': $('input[name=lastname]').val(),
                'auto_withdraw' : $('select[name=auto_withdraw]').val(),
            },
            function( data ) {
                $('#message').empty();
                if (data.result)
                    $('#message').append('<div class=success><span>'+ data.message +'</span></div>');
                else
                    $('#message').append('<div class=error><span>'+ data.message +'</span></div>');
                setTimeout(function(){
                    $('#message').slideUp(1000);
                },3000)
        }, "json");
    }
    function submit_change_password()
    {
        $('#message2').empty();
        $('#message2').show();
        if ($('input[name=newpassword]').val() != $('input[name=confirmnewpassword]').val())
        {
            $('#message2').append('<div class=error><span>Password error.</span></div>');
            setTimeout(function(){
                $('#message2').slideUp(1000);
            },3000)
            return;
        }
        $.post( '/account/ajax_updatePassword/', 
            {
                'password': $('input[name=password]').val(),
                'newpassword': $('input[name=newpassword]').val(),
                'confirmnewpassword': $('input[name=confirmnewpassword]').val(),
            },
            function( data ) {
                //clear val on fields
                $('input[name=password]').val('');
                $('input[name=newpassword]').val('');
                $('input[name=confirmnewpassword]').val('');
                //show message
                $('#message2').empty();
                if (data.result)
                    $('#message2').append('<div class=success><span>'+ data.message +'</span></div>');
                else
                    $('#message2').append('<div class=error><span>'+ data.message +'</span></div>');
                setTimeout(function(){
                    $('#message2').slideUp(1000);
                },3000)
        }, "json");
    }
-->
</script>